package com.algorithm.model;

public class ListNodeService {


    public static ListNode getListNode() {
        ListNode head = new ListNode(1);
        ListNode head2 = new ListNode(2);
        ListNode head3 = new ListNode(3);
        head.next = head2;
        head2.next = head3;
        return head;
    }


    public static void print(ListNode head) {
        while (head != null) {
            System.out.print(head.val + "->");
            head = head.next;
        }
        System.out.print("\b\b");
    }

    public static ListNode getByArray(int[] arr) {
        ListNode tmp, head = new ListNode(arr[0]);
        tmp = head;
        for (int i = 1; i < arr.length; i++) {
            tmp.next = new ListNode(arr[i]);
            tmp = tmp.next;
        }
        return head;
    }

    public static void main(String[] args) {
        print(getByArray(new int[]{-10,-9,-6,-4,1,9,9}));
    }

}
